<template>
    <div>
        <h3>Child</h3>
        <h5> {{ msg }} </h5>
        <h6>{{ app }}</h6>
        <button @click="passMsg">走你！</button>
    </div>
</template>

<script>
import bus from '../util/bus'
    export default {
        props: {
            msg: {
                type: String,
                default: ''
            }
        },
        data() {
            return {
                childMsg: 'child msg',
                app: ''
            }
        },
        methods: {
            // 子组件向父组件触发一个事件,然后去父组件监听这个事件
            passMsg() {
                this.$emit('showMsg', 'I am from Child')
            }
        },
        mounted () {
            console.log('attrs',this.$attrs)
            bus.$on('msg', (val) => {
                this.app = val    
            })
        }

        
    }
</script>

<style scoped>

</style>